<!DOCTYPE html>
<html lang="zh-cmn-Hans">

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="Expires" content="0" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Cache-control" content="no-cache" />
		<meta http-equiv="Cache" content="no-cache" />
		<title>首尔晶片扫描</title>
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<link rel="stylesheet" href="./4/lumen/bootstrap.css" media="screen" />
		<link rel="stylesheet" href="./_assets/css/custom.min.css" />
		<link rel="stylesheet" href="./layui/css/layui.css">
	</head>

	<body>
		<!-- 手风琴测试区 -->
		<div class="layui-collapse" lay-accordion>
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">生成自定义二维码</h2>
				<div class="layui-colla-content" id="wospe">
					<!-- 这里是需要打印的区域,也就是二维码区域 -->
					<div id="print_content">
						<div align="left" class="layui-row">
							<div id="qrcodeTable" class="layui-col-sm2"></div>
						</div>
						<div align="left" class="layui-row">
							<div id="PO_Str" class="layui-col-sm2"></div>
						</div>
					</div>
					<!-- 这里包一个生成二维码的功能 -->
					<button class="btn btn-primary" id="print">生成二维码并打印</button>
				</div>
			</div>

			<div class="layui-colla-item">
				<h2 class="layui-colla-title">按条件查询导出</h2>
				<div class="layui-colla-content">
					<!-- 这里包一个数据库查询的功能 -->
					<form action="Select2CSV.php" method="post">
						开始时间: <input type="date" name="sjj1" /> 结束时间: <input type="date" name="sjj2" /> 工单号: <input type="text" name="GongDan" />
						<input type="submit" class="btn btn-primary" value="导出" />
						<br/>(提示:数据过大，要同时指定开始时间和结束时间或指定工单号才可以导出)
					</form>
				</div>
			</div>
		</div>

		<div class="container">
			<legend>首尔芯片扫描</legend>
			<form>
				<fieldset>
					<div class="form-group row">
						<label class="col-sm-2 col-form-label" for="inputDefault">晶片料号:</label>
						<div class="col-sm-10">
							<input class="form-control" placeholder="验证多晶片产品时,晶片料号要优先输入!" id="cho" type="text" />
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 col-form-label" for="inputDefault">工单:</label>
						<div class="col-sm-10">
							<input class="form-control" placeholder="W7C14H" id="wo" type="text" />
						</div>
					</div>
					<div class="row" id="woDesc">
					</div>
					<div class="form-group row">
						<label class="col-sm-2 col-form-label" for="inputDefault">扫描二维码:</label>
						<div class="col-sm-10">
							<input class="form-control" placeholder="17620T4003-7250613" id="qr" type="text" />
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-1 col-form-label" for="inputDefault">数量:</label>
						<div class="col-sm-2">
							<input readonly="" class="form-control" id="qty" type="text" />
						</div>
						<label class="col-sm-1 col-form-label" for="inputDefault">累加量:</label>
						<div class="col-sm-2">
							<input readonly="" class="form-control" id="sqty" type="text" />
						</div>
						<label class="col-sm-1 col-form-label" for="inputDefault">每包累计:</label>
						<div class="col-sm-2">
							<input class="form-control" id="esqty" type="text" />
						</div>
						<button type="button" class="btn btn-primary" id="Clearesqty">清除每包累计</button>
					</div>
					<div class="form-group row">
						<div class="col-sm-1"></div>
						<div class="col-sm-6">
							<input type="text" class="form-control" placeholder="请输入当前蓝膜实际数量,然后按下右边的更新按钮" id="Up2Chip" />
						</div>
						<div class="col-sm-4">
							<button type="button" class="btn btn-primary" onclick="showUp(this)" id="btn_up">更新当前蓝膜实际数量</button>
						</div>
					</div>
					<!-- 外键20180228150653001序号 -->
					<div class="row">
						<table class="table table-hover" style="table-layout:fixed">
							<thead>
								<tr class="table-active">
									<th width="10%" scope="col">工单号</th>
									<th width="10%" scope="col">芯片种类</th>
									<th width="17%" scope="col">批号</th>
									<th width="10%" scope="col">规格</th>
									<th width="7%" scope="col">电压最小值</th>
									<th width="7%" scope="col">电压最大值</th>
									<th width="7%" scope="col">亮度最小值</th>
									<th width="7%" scope="col">亮度最大值</th>
									<th width="7%" scope="col">亮度均值</th>
									<th width="7%" scope="col">主波长最小值</th>
									<th width="7%" scope="col">主波长最大值</th>
									<th width="7%" scope="col">数量</th>
									<th width="7%" scope="col">序号</th>
									<th width="7%" scope="col">删除键</th>
								</tr>
							</thead>
							<tbody id="blues">
							</tbody>
						</table>
					</div>
				</fieldset>
			</form>
			<p class="lead">
				<a class="btn btn-primary btn-lg" href="index.html" role="button">返回</a>
			</p>
		</div>
		<script src="./js/jquery.min.js"></script>
		<script src="./layui/layui.js"></script>
		<script src="./js/jquery.qrcode.min.js"></script>
		<script src="./_vendor/popper.js/dist/umd/popper.min.js"></script>
		<script src="./_vendor/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="./_assets/js/custom.js"></script>
		<script>
			var sum = 0;
			var sum1 = 0;
			var i = 0;
			var del_id = null;
			var JiShu = 0;
			var disks;
			var disksB;
			var cks = new Array(20);
			var vfav = 0,
				poav = 0,
				wdav = 0;
			var v1 = 0,
				v2 = 0,
				v3 = 0,
				v4 = 0,
				v5 = 0,
				v6 = 0,
				v7 = 0,
				h1 = 0,
				h2 = 0,
				h3 = 0,
				h4 = 0,
				h5 = 0,
				h6 = 0,
				h7 = 0,
				w1 = 0,
				w2 = 0,
				w3 = 0,
				w4 = 0,
				w5 = 0,
				w6 = 0,
				w7 = 0;
			var jz = 0; //均值
			var jzjs = ""; //均值的文本计算
			var jsfh = {} //计算方式计算符号
			var dy = 0; //电压
			var dyjs = ""; //电压的文本计算
			var ld = 0; //电压
			var ldjs = ""; //电压的文本计算

			jsfh = {
				'>=': '>=',
				'≥': '>=',
				'<=': '<=',
				'≤': '<=',
				'<': '<',
				'＜': '<',
				'>': '>',
				'＞': '>',
				'=': '=',
				'＝': '='
			}

			$(document).ready(function() {
				layui.use(['form', 'element'], function() {});
				var form = layui.form;
				var element = layui.element;
				var print_click = "print"; //打印的按钮的id
				$("#" + print_click).bind("click", function() {
					//这里按下之后是生成二维码
					$("#qrcodeTable").html("");
					$("#PO_Str").html('<big><b>工单号：</big></b><br/>' + $("#wo").val());
					$("#qrcodeTable").qrcode({
						render: "table", // 渲染方式有table方式（IE兼容）和canvas方式
						width: 120, //宽度
						height: 120, //高度
						text: utf16to8($("#wo").val()), //内容
						typeNumber: -1, //计算模式
						correctLevel: 2, //二维码纠错级别
						background: "#ffffff", //背景颜色
						foreground: "#000000" //二维码颜色
					});
					var print_id = "print_content"; //要打印的div的id
					var k = $("#" + print_id).prop("outerHTML");
					<!-- $("body *").hide(); -->
					var myWindow = window.open('', ''); //定义一个打开的窗口给一个变量
					myWindow.document.write(k); //js原生打印画面方法
					myWindow.print(); //打开的窗口打印
				});
				//这里载入之后是生成二维码
				$("#PO_Str").html('<big><b>工单号：</big></b><br/>' + $("#wo").val());
				$("#qrcodeTable").qrcode({
					render: "table", // 渲染方式有table方式（IE兼容）和canvas方式
					width: 120, //宽度
					height: 120, //高度
					text: utf16to8($("#wo").val()), //内容
					typeNumber: -1, //计算模式
					correctLevel: 2, //二维码纠错级别
					background: "#ffffff", //背景颜色
					foreground: "#000000" //二维码颜色
				});
			});

			$("#wo").keypress(function(e) { //WO工单号按下回车后的代码
				var key = e.which;
				if(key == 13) {
					//这里按下回车之后是生成二维码
					$("#qrcodeTable").html("");
					$("#PO_Str").html('<big><b>工单号：</big></b><br/>' + $("#wo").val());
					$("#qrcodeTable").qrcode({
						render: "table", // 渲染方式有table方式（IE兼容）和canvas方式
						width: 120, //宽度
						height: 120, //高度
						text: utf16to8($("#wo").val()), //内容
						typeNumber: -1, //计算模式
						correctLevel: 2, //二维码纠错级别
						background: "#ffffff", //背景颜色
						foreground: "#000000" //二维码颜色
					});

					$("#wospe").attr('class', 'layui-colla-content layui-show');

					if($("#cho").val() != "") {
						if(/^A.{6}$/.test($("#cho").val())) {
							getwo($("#cho").val(), $("#wo").val());
						} else {
							layer.tips("<span style='color:red'><big><b>晶片料号不正确，请确认！</b></big></span>", $("#cho"), {
								tips: [2, '#fff']
							});
							return false;
						}
					} else {
						getwo('', $("#wo").val());
					}

					$("#qr").select();
				}
			});
			//S-30MBMUD-C,17C120650VY008212,457CI155,17045,   --3
			//VF:3.02,3.07,3.10,0.02,  --4，5，6，7
			//PO:155.0,156.7,161.0,1.11, --8，9，10，11
			//WD:457.5,458.2,460.0,0.58,--12，13，14，15
			//00-00-F1-000-000-V
			$("#qr").keypress(function(e) { //二维码的输入框按下回车
				var key = e.which;
				if(key == 13) {
					qrs = $("#qr").val().split(";"); //把二维码的内容拆分
					//通过判断扫描二维码的长度分类
					if(qrs.length == 17) {

						//通过二维码的下标3是不是数字分类
						//是数字
						if(/^\d+\.?\d*$/.test(qrs[3])) {
							i++;
							bg = ""; //
							vfav = qrs[11]; //电压均值
							poav = qrs[8]; //平均亮度
							wdav = qrs[5]; //平均波长

							smvfs = parseFloat(qrs[10]); //smvfs=扫描电压小
							smvfl = parseFloat(qrs[12]); //smvfl=扫描电压大

							if(dyjs) //存在电压的再判断,就进行且判断
							{
								if(eval(smvfs + dyjs) && eval(smvfl + dyjs)) {
									bg1 = "bgcolor='green'";
									bg2 = "bgcolor='green'";
								} else {
									bg1 = "bgcolor='red'";
									bg2 = "bgcolor='red'";
								}
							} else //没有电压判断就走原来的判断模式
							{
								if(smvfs < v2 || smvfs > v3) {
									bg1 = 'bgcolor="red"';
								} else {
									bg1 = 'bgcolor="green"';
								}
								if(smvfl > v3 || smvfl < v2) {
									bg2 = 'bgcolor="red"';
								} else {
									bg2 = 'bgcolor="green"';
								}
							}

							smpos = parseFloat(qrs[7]); //smpos=扫描亮度小

							smpol = parseFloat(qrs[9]); //smpol=扫描亮度大

							if(ldjs) //如果存在亮度的再判断,就进行且判断
							{
								if(eval(smpos + ldjs) && eval(smpol + ldjs)) {
									bg3 = "bgcolor='green'";
									bg4 = "bgcolor='green'";
								} else {
									bg3 = "bgcolor='red'";
									bg4 = "bgcolor='red'";
								}
							} else //如果没有亮度判断就走原来的判断模式
							{
								if(smpos < h2 || smpos > h3) {
									bg3 = 'bgcolor="red"';
								} else {
									bg3 = 'bgcolor="green"';
								}
								if(smpol > h3 || smpol < h2) {
									bg4 = 'bgcolor="red"';
								} else {
									bg4 = 'bgcolor="green"';
								}
							}

							poav = parseFloat(qrs[8]); //poav=亮度均值

							if(jzjs) //如果存在均值判断,就进行判断
							{
								if(eval(poav + jzjs)) {
									bg7 = 'bgcolor="green"';
								} else {
									bg7 = 'bgcolor="red"';
								}
							} else //否则就直接通过
							{
								bg7 = 'bgcolor="green"';
							}

							smwds = parseFloat(qrs[4]); //smwds=扫描波长小
							if(smwds < w2 || smwds > w3) {
								bg5 = 'bgcolor="red"';
							} else {
								bg5 = 'bgcolor="green"';
							}
							smwdl = parseFloat(qrs[6]); //smwdl=扫描波长大
							if(smwdl > w3 || smwdl < w2) {
								bg6 = 'bgcolor="red"';
							} else {
								bg6 = 'bgcolor="green"';
							}

							//SAVE DB这里开始传输数据到数据库存储
							//日期时间, 工单号, 成品料号, 芯片料号, 芯片规格, 芯片电压, 芯片亮度, 芯片波长, 扫描品号, 扫描批号, 扫描规格, 扫描电压小, 扫描电压大, 扫描亮度小, 扫描亮度大, 扫描波长小, 扫描波长大, 数量, 二维码内容
							//date函数, Str1传入Chip_item参数,传递到php
							//文本=`工单号·······················   ··成品料号··· ··     ·芯片料号·····     ·····规格``·········电压```········亮度```·········波长```···```·工单数量·`````····扫描品号········批号``··········规格`········扫描电压小··········大··········亮度小·········大···········波长小···········大·········数量········二维码内容··············外键

							$Str1 = "'" + $("#wo").val() + "', '" + qrs[0] + "', '" + qrs[1] + "', '" + qrs[3] + "', '" + qrs[4] + "', '" + qrs[0] + "', '" + qrs[6] + "', '" + qrs[4] + "', '" + qrs[0] + "', '" + qrs[3] + "', '" + qrs[2] + "', '" + smvfs + "', '" + smvfl + "', '" + smpos + "', '" + smpol + "', '" + smwds + "', '" + smwdl + "', '" + qrs[3] + "', '" + $("#qr").val() + "', '" + del_id + "', '" + vfav + "', '" + poav + "', '" + wdav + "', '" + qrs[7] + "'"
							if($("#wo").val() == "") {
								layer.msg("工单号不能为空！");
							} else {
								$.ajax({
									type: 'POST',
									url: "http://172.31.3.27:84/index.php?s=/tdled/chip/chip", //172.31.3.27:84//127.0.0.1:85,//POST傳一個超長字串到後端
									//data: 'Chip_item='+$Str1,
									data: "chjson=" + JSON.stringify({
										'wo': $("#wo").val(),
										'chpn': qrs[0],
										'smwo': qrs[2],
										'smsm': qrs[1],
										'smvfs': qrs[10],
										'smvfl': qrs[12],
										'smpos': qrs[7],
										'smpol': qrs[9],
										'smwds': qrs[4],
										'smwdl': qrs[6],
										'qty': qrs[3],
										//'qrc': qrs[],
										'vfav': qrs[11],
										'poav': qrs[8],
										'wdav': qrs[5],
										'smmcs': qrs[13],
										'smmcl': qrs[15],
										'mcav': qrs[14],

									}),
									dataType: "json",
									success: function(sss) {

										if(sss.msg) {
											layer.msg(sss.msg);
										}

										if(sss.CD <= 1) {
											//layer.msg(sss.msg);
											var delid = sss.DelId;
											del_id = delid;
											html =
												'<tr id=' + del_id + '>' +
												'<td>' + $("#wo").val() + '</td>' + //工单号,这里是输出网页代码
												'<td>' + qrs[0] + '</td> ' + //扫描品号
												'<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' + qrs[2] + '</td>' + //扫描批号
												'<td>' + qrs[1] + '</td>' + //扫描规格

												'<td ' + bg1 + '">' + qrs[10] + '</td>' + //扫描电压小
												'<td ' + bg2 + '">' + qrs[12] + '</td>' + //扫描电压大
												'<td ' + bg3 + '">' + qrs[7] + '</td>' + //扫描亮度小
												'<td ' + bg4 + '">' + qrs[9] + '</td>' + //扫描亮度大
												'<td ' + bg7 + '">' + qrs[8] + '</td>' + //扫描亮度均值
												'<td ' + bg5 + '">' + qrs[4] + '</td>' + //扫描波长小
												'<td ' + bg6 + '">' + qrs[6] + '</td>' + //扫描波长大

												'<td id="upQty' + del_id + '" >' + qrs[3] + '</td>' + //扫描数量
												'<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' + del_id + '</td> ' + //数据库序号
												'<td><button type="button" class="btn btn-primary" onclick="showDetails(this)" id="del' + del_id + '" data-qty="' + qrs[3] + '" data-type="' + del_id + '" >刪除</button></td> ' +
												'</tr>';
											sum += parseFloat(qrs[3]);
											sum1 += parseFloat(qrs[3]);
											$("#sqty").val(sum); //这里是所有数量合计
											$("#esqty").val(sum1); //这里是每包数量合计,提供手动清零
											//这里准备在芯片当前信息框内写入当前二维码信息
											$("#blues").prepend(html);
											if(i > 100) //保留最新的100条数据,避免卡顿
											{
												$("#blues tr:last").remove();
											}
											$("#qr").select();
										}
									}
								});
							}

						} else {
							//不是数字

							i++;
							bg = ""; //
							vfav = qrs[5]; //电压均值
							poav = qrs[8]; //平均亮度
							wdav = qrs[14]; //平均波长

							smvfs = parseFloat(qrs[4]); //smvfs=扫描电压小
							smvfl = parseFloat(qrs[6]); //smvfl=扫描电压大

							s = parseFloat(qrs[4]); //smvfs=扫描电压小
							//smvfl = parseFloat(qrs[7]); //smvfl=扫描电压大

							if(dyjs) //存在电压的再判断,就进行且判断
							{
								if(eval(smvfs + dyjs) && eval(smvfl + dyjs)) {
									bg1 = "bgcolor='green'";
									bg2 = "bgcolor='green'";
								} else {
									bg1 = "bgcolor='red'";
									bg2 = "bgcolor='red'";
								}
							} else //没有电压判断就走原来的判断模式
							{
								if(smvfs < v2 || smvfs > v3) {
									bg1 = 'bgcolor="red"';
								} else {
									bg1 = 'bgcolor="green"';
								}
								if(smvfl > v3 || smvfl < v2) {
									console.log(v3);
									bg2 = 'bgcolor="red"';
								} else {
									bg2 = 'bgcolor="green"';
								}
							}

							smpos = parseFloat(qrs[7]); //smpos=扫描亮度小
							smpol = parseFloat(qrs[9]); //smpol=扫描亮度大

							if(ldjs) //如果存在亮度的再判断,就进行且判断
							{
								if(eval(smpos + ldjs) && eval(smpol + ldjs)) {
									bg3 = "bgcolor='green'";
									bg4 = "bgcolor='green'";
								} else {
									bg3 = "bgcolor='red'";
									bg4 = "bgcolor='red'";
								}
							} else //如果没有亮度判断就走原来的判断模式
							{
								if(smpos < h2 || smpos > h3) {
									bg3 = 'bgcolor="red"';
								} else {
									bg3 = 'bgcolor="green"';
								}
								if(smpol > h3 || smpol < h2) {
									bg4 = 'bgcolor="red"';
								} else {
									bg4 = 'bgcolor="green"';
								}
							}

							poav = parseFloat(qrs[8]); //poav=亮度均值

							if(jzjs) //如果存在均值判断,就进行判断
							{
								if(eval(poav + jzjs)) {
									bg7 = 'bgcolor="green"';
								} else {
									bg7 = 'bgcolor="red"';
								}
							} else //否则就直接通过
							{
								bg7 = 'bgcolor="green"';
							}

							smwds = parseFloat(qrs[13]); //smwds=扫描波长小
							if(smwds < w2 || smwds > w3) {
								bg5 = 'bgcolor="red"';
							} else {
								bg5 = 'bgcolor="green"';
							}
							smwdl = parseFloat(qrs[15]); //smwdl=扫描波长大
							if(smwdl > w3) {
								bg6 = 'bgcolor="red"';
							} else {
								bg6 = 'bgcolor="green"';
							}

							//SAVE DB这里开始传输数据到数据库存储
							//日期时间, 工单号, 成品料号, 芯片料号, 芯片规格, 芯片电压, 芯片亮度, 芯片波长, 扫描品号, 扫描批号, 扫描规格, 扫描电压小, 扫描电压大, 扫描亮度小, 扫描亮度大, 扫描波长小, 扫描波长大, 数量, 二维码内容
							//date函数, Str1传入Chip_item参数,传递到php
							//文本=`工单号·························成品料号······      芯片料号·······      ···规格``· ········电压```········亮度```·········波长```···```·工单数量·`````····扫描品号········批号``··········规格`········扫描电压小··········大··········亮度小·········大···········波长小···········大·········数量········二维码内容··············外键

							$Str1 = "'" + $("#wo").val() + "', '" + null + "', '" + qrs[0] + "', '" + qrs[2] + "', '" + qrs[4] + "', '" + qrs[0] + "', '" + qrs[6] + "', '" + qrs[4] + "', '" + qrs[0] + "', '" + qrs[3] + "', '" + qrs[2] + "', '" + smvfs + "', '" + smvfl + "', '" + smpos + "', '" + smpol + "', '" + smwds + "', '" + smwdl + "', '" + qrs[3] + "', '" + $("#qr").val() + "', '" + del_id + "', '" + vfav + "', '" + poav + "', '" + wdav + "', '" + qrs[7] + "'"
							if($("#wo").val() == "") {
								layer.msg("工单号不能为空！");
							} else {
								$.ajax({
									type: 'POST',
									url: "http://172.31.3.27:84/index.php?s=/tdled/chip/chip17", //172.31.3.27:84//127.0.0.1:85,//POST傳一個超長字串到後端
									//data: 'Chip_item='+$Str1,
									data: "chjson=" + JSON.stringify({
										'wo': $("#wo").val(),
										//'chpn': "null",
										'smwo': qrs[1],
										'smsm': qrs[0],
										'smvfs': qrs[4],
										'smvfl': qrs[6],
										'smpos': qrs[7],
										'smpol': qrs[9],
										'smwds': qrs[13],
										'smwdl': qrs[15],
										'qty': qrs[2],
										//'qrc': qrs[],
										'vfav': qrs[5],
										'poav': qrs[8],
										'wdav': qrs[14],
										'smmcs': qrs[10],
										'smmcl': qrs[12],
										'mcav': qrs[11],
										'unfield': qrs[3],

									}),
									dataType: "json",
									success: function(sss) {

										if(sss.msg) {
											layer.msg(sss.msg);
										}

										if(sss.CD <= 1) {
											var delid = sss.DelId;
											del_id = delid;
											html =
												'<tr id=' + del_id + '>' +
												'<td>' + $("#wo").val() + '</td>' + //工单号,这里是输出网页代码
												'<td>' + "null" + '</td> ' + //扫描品号
												'<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' + qrs[1] + '</td>' + //扫描批号
												'<td>' + qrs[1] + '</td>' + //扫描规格

												'<td ' + bg1 + '">' + qrs[4] + '</td>' + //扫描电压小
												'<td ' + bg2 + '">' + qrs[6] + '</td>' + //扫描电压大
												'<td ' + bg3 + '">' + qrs[7] + '</td>' + //扫描亮度小
												'<td ' + bg4 + '">' + qrs[9] + '</td>' + //扫描亮度大
												'<td ' + bg7 + '">' + qrs[8] + '</td>' + //扫描亮度均值
												'<td ' + bg5 + '">' + qrs[13] + '</td>' + //扫描波长小
												'<td ' + bg6 + '">' + qrs[15] + '</td>' + //扫描波长大

												'<td id="upQty' + del_id + '" >' + qrs[2] + '</td>' + //扫描数量
												'<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' + del_id + '</td> ' + //数据库序号
												'<td><button type="button" class="btn btn-primary" onclick="showDetails(this)" id="del' + del_id + '" data-qty="' + qrs[2] + '" data-type="' + del_id + '" >刪除</button></td> ' +
												'</tr>';
											sum += parseFloat(qrs[2]);
											sum1 += parseFloat(qrs[2]);
											$("#sqty").val(sum); //这里是所有数量合计
											$("#esqty").val(sum1); //这里是每包数量合计,提供手动清零
											//这里准备在芯片当前信息框内写入当前二维码信息
											$("#blues").prepend(html);
											if(i > 100) //保留最新的100条数据,避免卡顿
											{
												$("#blues tr:last").remove();
											}
											$("#qr").select();
										}
									}
								});
							}

						}

					} else if(qrs.length == 18) {
						i++;
						bg = ""; //
						vfav = qrs[12]; //电压均值
						poav = qrs[9]; //亮度均值
						wdav = qrs[6]; //波长均值

						smvfs = parseFloat(qrs[11]); //smvfs=扫描电压小
						smvfl = parseFloat(qrs[13]); //smvfl=扫描电压大

						if(dyjs) //存在电压的再判断,就进行且判断
						{
							if(eval(smvfs + dyjs) && eval(smvfl + dyjs)) {
								bg1 = "bgcolor='green'";
								bg2 = "bgcolor='green'";
							} else {
								bg1 = "bgcolor='red'";
								bg2 = "bgcolor='red'";
							}
						} else //没有电压判断就走原来的判断模式
						{
							if(smvfs < v2 || smvfs > v3) {
								bg1 = 'bgcolor="red"';
							} else {
								bg1 = 'bgcolor="green"';
							}
							if(smvfl > v3 || smvfl < v2) {
								bg2 = 'bgcolor="red"';
							} else {
								bg2 = 'bgcolor="green"';
							}
						}

						smpos = parseFloat(qrs[8]); //smpos=扫描亮度小
						smpol = parseFloat(qrs[10]); //smpol=扫描亮度大

						if(ldjs) //如果存在亮度的再判断,就进行且判断
						{
							if(eval(smpos + ldjs) && eval(smpol + ldjs)) {
								bg3 = "bgcolor='green'";
								bg4 = "bgcolor='green'";
							} else {
								bg3 = "bgcolor='red'";
								bg4 = "bgcolor='red'";
							}
						} else //如果没有亮度判断就走原来的判断模式
						{
							if(smpos < h2 || smpos > h3) {
								bg3 = 'bgcolor="red"';
							} else {
								bg3 = 'bgcolor="green"';
							}
							if(smpol > h3 || smpol < h2) {
								bg4 = 'bgcolor="red"';
							} else {
								bg4 = 'bgcolor="green"';
							}
						}

						poav = parseFloat(qrs[9]); //poav=亮度均值

						if(jzjs) //如果存在均值判断,就进行判断
						{
							if(eval(poav + jzjs)) {
								bg7 = 'bgcolor="green"';
							} else {
								bg7 = 'bgcolor="red"';
							}
						} else //否则就直接通过
						{
							bg7 = 'bgcolor="green"';
						}

						smwds = parseFloat(qrs[5]); //smwds=扫描波长小
						if(smwds < w2 || smwds > w3) {
							bg5 = 'bgcolor="red"';
						} else {
							bg5 = 'bgcolor="green"';
						}
						smwdl = parseFloat(qrs[7]); //smwdl=扫描波长大
						if(smwdl > w3 || smwdl < w2) {
							bg6 = 'bgcolor="red"';
						} else {
							bg6 = 'bgcolor="green"';
						}

						//SAVE DB这里开始传输数据到数据库存储
						//日期时间, 工单号, 成品料号, 芯片料号, 芯片规格, 芯片电压, 芯片亮度, 芯片波长, 扫描品号, 扫描批号, 扫描规格, 扫描电压小, 扫描电压大, 扫描亮度小, 扫描亮度大, 扫描波长小, 扫描波长大, 数量, 二维码内容
						//date函数, Str1传入Chip_item参数,传递到php
						//文本=`工单号·······················   ··成品料号··· ··     ·芯片料号·····     ·····规格``·········电压```········亮度```·········波长```···```·工单数量·`````····扫描品号········批号``··········规格`········扫描电压小··········大··········亮度小·········大···········波长小···········大·········数量········二维码内容··············外键

						$Str1 = "'" + $("#wo").val() + "', '" + qrs[0] + "', '" + qrs[1] + "', '" + qrs[3] + "', '" + qrs[4] + "', '" + qrs[0] + "', '" + qrs[6] + "', '" + qrs[4] + "', '" + qrs[0] + "', '" + qrs[3] + "', '" + qrs[2] + "', '" + smvfs + "', '" + smvfl + "', '" + smpos + "', '" + smpol + "', '" + smwds + "', '" + smwdl + "', '" + qrs[3] + "', '" + $("#qr").val() + "', '" + del_id + "', '" + vfav + "', '" + poav + "', '" + wdav + "', '" + qrs[7] + "'"
						if($("#wo").val() == "") {
							layer.msg("工单号不能为空！");
						} else {
							$.ajax({
								type: 'POST',
								url: "http://172.31.3.27:84/index.php?s=/tdled/chip/chip18", //172.31.3.27:84//127.0.0.1:85,//POST傳一個超長字串到後端
								//data: 'Chip_item='+$Str1,
								data: "chjson=" + JSON.stringify({
									'wo': $("#wo").val(),
									'chpn': qrs[0],
									'smwo': qrs[2],
									'smsm': qrs[1],
									'smvfs': qrs[11],
									'smvfl': qrs[13],
									'smpos': qrs[8],
									'smpol': qrs[10],
									'smwds': qrs[5],
									'smwdl': qrs[7],
									'qty': qrs[3],
									//'qrc': qrs[],
									'vfav': qrs[12],
									'poav': qrs[9],
									'wdav': qrs[6],
									'smmcs': qrs[14],
									'smmcl': qrs[16],
									'mcav': qrs[15],
									'unfield': qrs[4],
								}),
								dataType: "json",
								success: function(sss) {
									if(sss.msg) {
										layer.msg(sss.msg);
									}

									if(sss.CD <= 1) {
										var delid = sss.DelId;
										del_id = delid;
										html =
											'<tr id=' + del_id + '>' +
											'<td>' + $("#wo").val() + '</td>' + //工单号,这里是输出网页代码
											'<td>' + qrs[0] + '</td> ' + //扫描品号
											'<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' + qrs[2] + '</td>' + //扫描批号
											'<td>' + qrs[1] + '</td>' + //扫描规格

											'<td ' + bg1 + '">' + qrs[11] + '</td>' + //扫描电压小
											'<td ' + bg2 + '">' + qrs[13] + '</td>' + //扫描电压大
											'<td ' + bg3 + '">' + qrs[8] + '</td>' + //扫描亮度小
											'<td ' + bg4 + '">' + qrs[10] + '</td>' + //扫描亮度大
											'<td ' + bg7 + '">' + qrs[9] + '</td>' + //扫描亮度均值
											'<td ' + bg5 + '">' + qrs[5] + '</td>' + //扫描波长小
											'<td ' + bg6 + '">' + qrs[7] + '</td>' + //扫描波长大

											'<td id="upQty' + del_id + '" >' + qrs[3] + '</td>' + //扫描数量
											'<td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">' + del_id + '</td> ' + //数据库序号
											'<td><button type="button" class="btn btn-primary" onclick="showDetails(this)" id="del' + del_id + '" data-qty="' + qrs[3] + '" data-type="' + del_id + '" >刪除</button></td> ' +
											'</tr>';
										sum += parseFloat(qrs[3]);
										sum1 += parseFloat(qrs[3]);
										$("#sqty").val(sum); //这里是所有数量合计
										$("#esqty").val(sum1); //这里是每包数量合计,提供手动清零
										//这里准备在芯片当前信息框内写入当前二维码信息
										$("#blues").prepend(html);
										if(i > 100) //保留最新的100条数据,避免卡顿
										{
											$("#blues tr:last").remove();
										}
										$("#qr").select();
									}
								}
							});
						}
					}

				}
			});

			function showDetails(delete_id) {
				var delidType = delete_id.getAttribute("data-type"); //这个是Del_Id
				var cutQty = delete_id.getAttribute("data-qty"); //这个是要删减的值
				$.ajax({
					type: 'POST',
					url: "http://172.31.3.27:84/index.php?s=/tdled/chip/delchip", //172.31.3.27:84//127.0.0.1:85,//POST傳一個超長字串到後端
					data: "delid=" + delidType,
					dataType: "json",
					success: function(sss) {

						layer.msg(sss.msg);
						var XiaoMie = "#" + delidType;
						$(XiaoMie).remove();
						sum = parseFloat($("#sqty").val()) - parseFloat(cutQty);
						sum1 = parseFloat($("#esqty").val()) - parseFloat(cutQty);
						$("#sqty").val(sum); //这里是数量合计
						$("#esqty").val(sum1); //这里是数量合计

					}
				});
			}

			function showUp(up_id) {
				if($("#Up2Chip").val() == "") {
					layer.msg("请输入修改数量！");
					return;
				} else if($("#qr").val() == "") {
					layer.msg("请扫描芯片二维码！");
					return;
				} else {
					var up2ChipType = del_id; //当前的删除ID
					var up2ChipQty = parseFloat($("#Up2Chip").val()); //需要修改的数值
					$("#btn_up").attr({
						"disabled": true
					}); //設置為禁用
					$("#btn_up").html("更新中..."); //設置為禁用
					$.ajax({
						type: 'POST',
						url: "http://172.31.3.27:84/index.php?s=/tdled/chip/upchip", //172.31.3.27:84//127.0.0.1:85,//POST傳一個超長字串到後端
						data: "del_id=" + up2ChipType + "&Up_Qty=" + up2ChipQty,
						dataType: "json",
						success: function(sss) {
							layer.msg(sss.msg);
							var Gx = "#upQty" + del_id;
							sum = ($("#sqty").val() - $(Gx).html());
							sum += up2ChipQty;
							sum1 = ($("#esqty").val() - $(Gx).html());
							sum1 += up2ChipQty;
							$("#sqty").val(sum); //这里是数量合计
							$("#esqty").val(sum1); //这里是数量合计
							$(Gx).html(up2ChipQty); //把当前最新行的也改成一样的
							$("#del" + up2ChipType).attr('data-qty', up2ChipQty);
							$("#Up2Chip").val("");
							$("#btn_up").attr({
								"disabled": false
							}); //設置為启用
							$("#btn_up").html("更新当前蓝膜实际数量"); //設置标签状态
						}
					});
				}
			}

			$("#Clearesqty").on('click', function() {
				sum1 = 0;
				$("#esqty").val(sum1);
			});

			Date.prototype.format = function(fmt) { //这里是日期格式化公式
				var o = {
					"M+": this.getMonth() + 1, //月份
					"d+": this.getDate(), //日
					"h+": this.getHours(), //小时
					"m+": this.getMinutes(), //分
					"s+": this.getSeconds(), //秒
					"q+": Math.floor((this.getMonth() + 3) / 3), //季度
					"S": this.getMilliseconds() //毫秒
				};
				if(/(y+)/.test(fmt)) {
					fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				}
				for(var k in o) {
					if(new RegExp("(" + k + ")").test(fmt)) {
						fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
					}
				}
				return fmt;
			}

			function utf16to8(str) {
				var out, i, len, c;
				out = "";
				len = str.length;
				for(i = 0; i < len; i++) {
					c = str.charCodeAt(i);
					if((c >= 0x0001) && (c <= 0x007F)) {
						out += str.charAt(i);
					} else if(c > 0x07FF) {
						out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
						out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
						out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
					} else {
						out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
						out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
					}
				}
				return out;
			}

			function getwo(cho, wo) {
				$.ajax({
					url: "getwo.php?cho=" + cho + "&lot=" + wo,
					dataType: "text",
					success: function(data) {

						wos = data.split(","); //T5C50724L-03,A2996F0,714.240000,晶片/S-35EBMUD-H,2.9-3.2,230-240,455-457.5
						//如果v1字符不包含分号,就啟用原來的版本
						//wos[7] = "typ≥150";//假装生管要求均值大于150
						var patt1 = /[;]/; //通用判断是否两个分号拆开的值
						var patt2 = /\d+\.?\d*[-|—]\d+\.?\d*/; //3.1-3.3
						var patt3 = /typ[≥|≤|>=|<=|>|<|=|＞|＜|＝]/i; //均值的判断
						var patt4 = /vf[≥|≤|>=|<=|>|<|=|＞|＜|＝]/i; //电压的再判断
						var patt5 = /po[≥|≤|>=|<=|>|<|=|＞|＜|＝]/i; //亮度的再判断
						console.log("均值的判断" + (patt3.test(wos[7])));
						console.log("电压的再判断" + (patt4.test(wos[7])));
						console.log("电压的自定区间判断" + (patt2.test(wos[7])));
						console.log("判断是不是小于等于10V" + (/\d+\.?\d*(?=[-|—]\d+\.?\d*)/.exec(wos[7]) * 1 <= 10));
						if(patt3.test(wos[7])) {
							console.log("存在均值");
							jzjs = jsfh[/[≥|≤|>=|<=|>|<|=|＞|＜|＝]/.exec(wos[7])];
							jz = /(?<=typ\D{1,3})\d+\.?\d*/i.exec(wos[7]);
							jzjs += jz;
							console.log(jz + '丨' + jzjs + '丨' + eval("225" + jzjs));
							eval("225" + jzjs);
							//(?<=typ)\d+\.?\d*/
						}
						if(patt4.test(wos[7])) {
							console.log("存在电压再判断");
							dyjs = jsfh[/[≥|≤|>=|<=|>|<|=|＞|＜|＝]/.exec(wos[7])];
							dy = /(?<=vf\D{1,3})\d+\.?\d*/i.exec(wos[7]);
							dyjs += dy;
							console.log(dy + '丨' + dyjs + '丨' + eval("225" + dyjs));
							eval("225" + dyjs);
						}
						if(patt5.test(wos[7])) {
							console.log("存在亮度再判断");
							ldjs = jsfh[/[≥|≤|>=|<=|>|<|=|＞|＜|＝]/.exec(wos[7])];
							ld = /(?<=po\D{1,3})\d+\.?\d*/i.exec(wos[7]);
							ldjs += ld;
							console.log(ld + '丨' + ldjs + '丨' + eval("225" + ldjs));
							eval("225" + ldjs);
						}
						if(patt2.test(wos[7]) && /\d+\.?\d*(?=[-|—]\d+\.?\d*)/.exec(wos[7]) * 1 <= 10) { //如果备注包含电压,就用备注的来进行处理
							if(patt1.test(wos[7])) {
								console.log(wos[7].split(";"));
								v1 = wos[7].split(";"); //v1=工单电压拆分后的兩组数组
								console.log(v1);
								//v2,v3出現新BUG,v组合:3.1-3.2;2.9-3.5,备份旧代码
								//<!-- v2=parseFloat(v1[0].split("-")[0]);//v2=工单电压小 -->
								v4 = parseFloat(v1[0].split("-")[0]);
								v5 = parseFloat(v1[0].split("-")[1]);
								v6 = parseFloat(v1[1].split("-")[0]);
								v7 = parseFloat(v1[1].split("-")[1]);
								//取出四串电压值
								v2 = Math.min(v4, v5, v6, v7);
								console.log(v2);
								//<!-- v3=parseFloat(v1[1].split("-")[1]);//v3=工单电压大 -->
								v3 = Math.max(v4, v5, v6, v7);
								console.log(v3);
							} else {
								v2 = parseFloat(wos[7].split("-")[0]); //v2=旧电压小
								console.log(v2);
								v3 = parseFloat(wos[7].split("-")[1]); //v2=旧电压大
								console.log(v3);
							}
						} else { //否则就跑原来电压的线
							if(patt1.test(wos[4])) {
								console.log(wos[4].split(";"));
								v1 = wos[4].split(";"); //v1=工单电压拆分后的两组数组
								console.log(v1);
								//v2,v3出現新BUG,v组合:3.1-3.2;2.9-3.5,备份旧代码
								<!-- v2=parseFloat(v1[0].split("-")[0]);//v2=工单电压小 -->
								v4 = parseFloat(v1[0].split("-")[0]);
								v5 = parseFloat(v1[0].split("-")[1]);
								v6 = parseFloat(v1[1].split("-")[0]);
								v7 = parseFloat(v1[1].split("-")[1]);
								//取出四串电压值
								v2 = Math.min(v4, v5, v6, v7);
								console.log(v2);
								<!-- v3=parseFloat(v1[1].split("-")[1]);//v3=工单电压大 -->
								v3 = Math.max(v4, v5, v6, v7);
								console.log(v3);
							} else {
								v2 = parseFloat(wos[4].split("-")[0]); //v2=旧电压小
								console.log(v2);
								v3 = parseFloat(wos[4].split("-")[1]); //v2=旧电压大
								console.log(v3);
							}
						}
						//v2=parseFloat(wos[4].split("-")[1]);//v2=旧电压规則
						//如果h1字符不包含分号,就啟用原來的版本
						if(patt1.test(wos[5])) {
							console.log(wos[5].split(";"));
							h1 = wos[5].split(";"); //h1=工单亮度拆分后的两组数组
							console.log(h1);
							//h2,h3出現新BUG,h组合:162-169;148-155,备份旧代码
							<!-- h2=parseFloat(h1[0].split("-")[0]);//h2=工单亮度小 -->
							h4 = parseFloat(h1[0].split("-")[0]);
							h5 = parseFloat(h1[0].split("-")[1]);
							h6 = parseFloat(h1[1].split("-")[0]);
							h7 = parseFloat(h1[1].split("-")[1]);
							//取出四串亮度值
							h2 = Math.min(h4, h5, h6, h7);
							console.log(h2);
							<!-- h3=parseFloat(h1[1].split("-")[1]);//h3=工单亮度大 -->
							h3 = Math.max(h4, h5, h6, h7);
							console.log(h3);
						} else {
							h2 = parseFloat(wos[5].split("-")[0]); //h2=旧亮度小
							console.log(h2);
							h3 = parseFloat(wos[5].split("-")[1]); //h2=旧亮度大
							console.log(h3);
						}
						//h2=parseFloat(wos[5].split("-")[1]);//h2=旧亮度规則
						//如果w1字符不包含分号,就啟用原來的版本
						if(patt1.test(wos[6])) {
							w1 = wos[6].split(";");
							console.log(w1);
							w4 = parseFloat(w1[0].split("-")[0]);
							w5 = parseFloat(w1[0].split("-")[1]);
							w6 = parseFloat(w1[1].split("-")[0]);
							w7 = parseFloat(w1[1].split("-")[1]);
							//取出四串亮度值
							w2 = Math.min(w4, w5, w6, w7);
							console.log(w2);
							w3 = Math.max(w4, w5, w6, w7);
							console.log(w3);
						} else {
							w2 = parseFloat(wos[6].split("-")[0]); //w1=工单波长小
							w3 = parseFloat(wos[6].split("-")[1]); //w2=工单波长大
						}

						$("#woDesc").text(""); // 清空数据
						$("#blues").text(""); // 清空累积的数据
						sum = 0;
						sum1 = 0;
						$("#sqty").val(sum); //这里是数量合计
						$("#esqty").val(sum1); //这里是数量合计
						html =
							'<table class="table table-hover">' +
							'<thead>' +
							'<tr class="table-active">' +
							'<th scope="col">工单号</th>' +
							'<th scope="col">成品料号</th>' +
							'<th scope="col">芯片料号</th>' +
							'<th scope="col">品名规格</th>' +
							'<th scope="col">电压</th>' +
							'<th scope="col">亮度</th>' +
							'<th scope="col">波长</th>' +
							'<th scope="col">备注</th>' +
							'</tr>' +
							'</thead>' +
							'<tbody>' +
							'<tr >' +
							'<th scope="row">' + $("#wo").val() + '</th>' + //工单号
							'<td>' + wos[0] + '</td>' + //成品料号
							'<td>' + wos[1] + '</td>' + //芯片料号
							'<td>' + wos[3] + '</td>' + //品名规格
							'<td>' + wos[4] + '</th>' + //电压
							'<td>' + wos[5] + '</th>' + //亮度
							'<td>' + wos[6] + '</th>' + //波长
							'<td>' + wos[7] + '</th>' + //备注
							'</tr>' +
							'</tbody>' +
							'</table>';
						$("#woDesc").append(html);
						$("#qty").val(wos[2]);
					}
				});
			}
		</script>
	</body>

</html>